<template>
  <div>
    <van-nav-bar
      :title="row.reply_count ?row.reply_count+'条回复':'暂无回复' "
    >
    <template #left>
      <van-icon name="cross" @click="$emit('close-reply')"/>
    </template>
    </van-nav-bar>
    <div class="scroll-warp">
      <CommentItem :item='row'></CommentItem>
    <van-cell title="全部评论" />
   <CommentList type="c" :source="row.com_id" :list='list'></CommentList>
    </div>
   <div class="post-warp">
        <van-button round @click="isShowReplyPopup=true">评论</van-button>
    </div>
    <van-popup v-model="isShowReplyPopup" position="bottom" >
         <CommentPost :list='list' @onPostComment='PostCommentFn' :target='row.com_id' :artId='$route.params.articleId'></CommentPost>
    </van-popup>
  </div>
</template>

<script>
import CommentList from './commentList.vue'
import CommentItem from '@/components/CommentItem.vue'
import CommentPost from '@/components/CommentPost.vue'

export default {
  components: {
    CommentItem,
    CommentList,
    CommentPost
  },
  props: {
    row: {
      type: Object,
      required: true
    }
  },
  data () {
    return {
      list: [],
      isShowReplyPopup: false
    }
  },
  methods: {
    PostCommentFn (obj) {
      this.isShowReplyPopup = false
      this.list.unshift(obj)
    }
  }
}
</script>

<style scoped lang="less">
.van-nav-bar{
  /deep/.van-nav-bar__content{
  background: #fff;
  }
}
.post-warp {
  width: 100%;
  height: 100px;
  position: fixed;
  bottom: 0;
  border-top: 1px solid #ccc;
  display: flex;
  align-items: center;
  justify-content: center;
  .van-button {
    width: 640px;
    height: 80px;
  }
}
.scroll-warp{
  position: absolute;
  top: 92px;
  bottom: 102px;
  width: 100%;
  overflow: scroll;
}

</style>
